home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fritz: All Fritz
/
All Fritz.zip
/
All Fritz
/
FILES
/
PROGNG_C
/
CSUBR.LZH
/
R_JUST.C
< prev
next >
Wrap
C/C++ Source or Header
|
1985-12-13
|
886b
|
33 lines
/***********************************************************************/
/* */
/* Right justify string str in size length field. */
/* */
/***********************************************************************/
int r_just(str, size)
char *str;
int size;
{
char *s, *d;
int len, count;
len = strlen(str); /* get string length */
if (len > size) /* truncate, if necessary */
str[size] = 0x00;
else if (len < size) {
d = str + size; /* copy to leave room */
s = str + len;
count = len + 1;
while (count--)
*d-- = *s--;
count = size - len; /* number of blanks to insert */
s = str;
while (count--)
*s++ = ' '; /* add leading blanks */
}
return str;
}